#include "Head.h"

#if 0
using namespace std;

vector<int> PortUsedMap;

void listPortUsed(void)
{
	string cmd = "sudo netstat -lnt | awk 'NR>2{print $4}' | grep -E '(0.0.0.0:|:::)' | sed 's/.*://' | sort -n | uniq > listPortUsed.txt";
	system(cmd.c_str());

	std::ifstream _in("listPortUsed.txt", std::ifstream::in);
	std::string line;
	int port;

	vector<int>().swap(PortUsedMap);//先清空原来内容
	while (getline(_in, line))
	{
		port = atoi(line.c_str());
		PortUsedMap.push_back(port);
	}
}

int main()
{
	listPortUsed();

	vector<int>::iterator itr = PortUsedMap.begin();
	for (; itr != PortUsedMap.end(); ++itr)
		cout << *itr << endl;

	getchar();

}
#endif // 1
